//
//  NewEventViewBasicCell.swift
//  YOKO
//
//  Created by Zoe_G on 16/5/21.
//  Copyright © 2016年 15Tec. All rights reserved.
//

import UIKit

protocol  NewEventCellDelegate{
    func timeCellHeightDidChange(cellHeight: CGFloat)
//    func reminderCellHeightDidChange(cellHeight: CGFloat)
    func textViewCellHeightDidChange(cellHeight: CGFloat)
    func selectingEventType()
    func swithWholeDay(isOn: Bool)
    func switchEndDate(isOn: Bool)
}

class NewEventViewBasicCell: UITableViewCell {
    
    let notify = NSNotificationCenter.defaultCenter()
    
    var iconLineType: CellLineType = CellLineType.LineNone
    var hasIcon: Bool = true
    var iconView: UIImageView! = nil
    
    var imgName: String = ""
    var rightBtnImgName = ""
    var isRightBtnAction: Bool = true
    var cellTitle = ""
    var switchBtnImgName = ""
    var hasSwitchBtn: Bool = false
    
    var textViewCellHeight: CGFloat = 52.0 {
        didSet{
            self.delegate.textViewCellHeightDidChange(textViewCellHeight)
        }
    }
    
    var endTimeCellHeight: CGFloat = 52.0 {
        didSet {
            self.delegate.timeCellHeightDidChange(endTimeCellHeight)
        }
    }
    
//    var reminderCellHeight: CGFloat = 52.0 {
//        didSet {
//            self.delegate.reminderCellHeightDidChange(reminderCellHeight)
//        }
//    }
    
    var delegate: NewEventCellDelegate! = nil

    override func awakeFromNib() {
        super.awakeFromNib()
        
        iconView = UIImageView()
        iconView.frame = CGRectMake(8, 8, 36, 36)
        self.addSubview(iconView)
        
        // Initialization code
    }
    
    override func drawRect(rect: CGRect) {
        
        iconView.image = UIImage(named: imgName)
        
        let lineColor = YOKOColor.TypeColors[0].colorWithAlphaComponent(0.06)
        
        switch  iconLineType {
        case .LineNone:
            break
        case .LineLast:
            DrawUtil.drawLine(CGPointMake(26.0, 0.0), end: CGPointMake(26.0, self.bounds.height/2), withColor: lineColor, withWidth: 2)
        case .LineFirst:
            DrawUtil.drawLine(CGPointMake(26.0, self.bounds.height/2), end: CGPointMake(26.0, self.bounds.height), withColor: lineColor, withWidth: 2)
        case .LineMiddle:
            DrawUtil.drawLine(CGPointMake(26.0, 0.0), end: CGPointMake(26.0, self.bounds.height), withColor: lineColor, withWidth: 2)
            
        }
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
